<!DOCTYPE html>
<html lang="zh">

<head>
  <meta charset="utf-8">
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no" />
  <title>小会计财税管理系统</title>
  <link rel="icon" href="favicon.ico" type="image/ico">
  <meta name="keywords" content="小会计财税管理系统">
  <meta name="description" content="小会计财税管理系统">
  <meta name="author" content="yinqi">
  <link href="css/bootstrap.min.css" rel="stylesheet">
  <link href="css/materialdesignicons.min.css" rel="stylesheet">
  <link href="css/style.min.css" rel="stylesheet">
  <link href="https://cdn.bootcss.com/zTree.v3/3.5.39/css/zTreeStyle/zTreeStyle.css" rel="stylesheet">
  <link type="application/rss+xml" rel="alternate" href="https://www.cnblogs.com/dxdblog/rss" />
  <link type="application/rsd+xml" rel="EditURI" href="https://www.cnblogs.com/dxdblog/rsd.xml" />
  <link type="application/wlwmanifest+xml" rel="wlwmanifest" href="https://www.cnblogs.com/dxdblog/wlwmanifest.xml" />
  <script src="https://eqcn.ajz.miesnfu.com/wp-content/plugins/wp-3d-pony/live2dw/lib/L2Dwidget.min.js"></script>
  <link href="icon/iconfont.css" rel="stylesheet">

</head>

<body style="overflow-x: hidden;overflow-y: hidden;">

  <div class="lyear-layout-web" id="app">
    <div class="lyear-layout-container">
      <!--左侧导航-->
      <aside class="lyear-layout-sidebar">

        <!-- logo -->
        <div id="logo" class="sidebar-header">
          <a><img src="images/4.png" style="transform: scale(0.9)" title="LightYear" alt="LightYear" /></a>
        </div>
        <div class="lyear-layout-sidebar-scroll">
          <nav class="sidebar-main">
            <template>
              <div class="index-menu">
                <div class="index-nav">
                  <el-menu :unique-opened="true" text-color="#000" class="el-menu-vertical-left"
                    active-text-color="#000" router>
                    <el-menu-item index="999">
                      <i class="el-icon-location" style="margin-left: -3px;"></i>
                      <span class="el-menu-item-name" style="margin-left: 7px;"
                        @click="go('welcome2.html')">后台首页</span>
                    </el-menu-item>
                    <el-submenu v-for="(item,index) in data" :index="item.id" :key="item.id">
                      <template slot="title">
                        <i class="iconfont iconbussiness-man"></i>
                        <span class="el-submenu-name" style="margin-left: 16px;"
                          @click="go(item.url)">{{item.name}}</span>
                      </template>
                      <el-menu-item class="main_left" v-for="(menu,index) in item.children" @click="go(menu.url)"
                        :key="menu.id">
                        <i class="iconfont iconservice" style="margin-left: -4px;"></i>
                        <span class="el-menu-item-name">{{menu.name}}</span>
                      </el-menu-item>
                    </el-submenu>
                  </el-menu>
                </div>

              </div>
            </template>
          </nav>
        </div>
      </aside>
      <!--End 左侧导航-->

      <!--头部信息-->
      <header class="lyear-layout-header">

        <nav class="navbar navbar-default">
          <div class="topbar">

            <div class="topbar-left">
              <div class="lyear-aside-toggler">
                <span class="lyear-toggler-bar"></span>
                <span class="lyear-toggler-bar"></span>
                <span class="lyear-toggler-bar"></span>
              </div>
              <span class="navbar-page-title"> 后台首页 </span>
            </div>
            <!-- href="lyear_pages_login.html" -->
            <ul class="topbar-right">
              <li class="dropdown dropdown-profile">
                <a href="javascript:void(0)" data-toggle="dropdown">
                  <img class="img-avatar img-avatar-48 m-r-10" src="images/uu.png" alt="文献资源" />
                  <span>{{username}}<span class="caret"></span></span>
                </a>
                <ul class="dropdown-menu dropdown-menu-right">
                  <li> <a type="button" data-toggle="modal" @click="person()" data-target="#myModal2"><i
                        class="mdi mdi-account"></i> 个人信息</a> </li>
                  <li> <a type="button" data-toggle="modal" @click="personpwd()" data-target="#myModal3"><i
                        class="mdi mdi-lock-outline"></i> 修改密码</a> </li>
                  <li class="divider"></li>
                  <li> <a type="button" @click="error()"><i class="mdi mdi-logout-variant"></i> 退出登录</a> </li>
                </ul>
              </li>
              <!--切换主题配色-->
              <li class="dropdown dropdown-skin">
                <span data-toggle="dropdown" class="icon-palette"><i class="mdi mdi-palette"></i></span>
                <ul class="dropdown-menu dropdown-menu-right" data-stopPropagation="true">
                  <li class="drop-title">
                    <p>主题</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="site_theme" value="default" id="site_theme_1" checked>
                      <label for="site_theme_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="site_theme" value="dark" id="site_theme_2">
                      <label for="site_theme_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="site_theme" value="translucent" id="site_theme_3">
                      <label for="site_theme_3"></label>
                    </span>
                  </li>
                  <li class="drop-title">
                    <p>LOGO</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="logo_bg" value="default" id="logo_bg_1" checked>
                      <label for="logo_bg_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_2" id="logo_bg_2">
                      <label for="logo_bg_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_3" id="logo_bg_3">
                      <label for="logo_bg_3"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_4" id="logo_bg_4">
                      <label for="logo_bg_4"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_5" id="logo_bg_5">
                      <label for="logo_bg_5"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_6" id="logo_bg_6">
                      <label for="logo_bg_6"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_7" id="logo_bg_7">
                      <label for="logo_bg_7"></label>
                    </span>
                    <span>
                      <input type="radio" name="logo_bg" value="color_8" id="logo_bg_8">
                      <label for="logo_bg_8"></label>
                    </span>
                  </li>
                  <li class="drop-title">
                    <p>头部</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="header_bg" value="default" id="header_bg_1" checked>
                      <label for="header_bg_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_2" id="header_bg_2">
                      <label for="header_bg_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_3" id="header_bg_3">
                      <label for="header_bg_3"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_4" id="header_bg_4">
                      <label for="header_bg_4"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_5" id="header_bg_5">
                      <label for="header_bg_5"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_6" id="header_bg_6">
                      <label for="header_bg_6"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_7" id="header_bg_7">
                      <label for="header_bg_7"></label>
                    </span>
                    <span>
                      <input type="radio" name="header_bg" value="color_8" id="header_bg_8">
                      <label for="header_bg_8"></label>
                    </span>
                  </li>
                  <li class="drop-title">
                    <p>侧边栏</p>
                  </li>
                  <li class="drop-skin-li clearfix">
                    <span class="inverse">
                      <input type="radio" name="sidebar_bg" value="default" id="sidebar_bg_1" checked>
                      <label for="sidebar_bg_1"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_2" id="sidebar_bg_2">
                      <label for="sidebar_bg_2"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_3" id="sidebar_bg_3">
                      <label for="sidebar_bg_3"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_4" id="sidebar_bg_4">
                      <label for="sidebar_bg_4"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_5" id="sidebar_bg_5">
                      <label for="sidebar_bg_5"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_6" id="sidebar_bg_6">
                      <label for="sidebar_bg_6"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_7" id="sidebar_bg_7">
                      <label for="sidebar_bg_7"></label>
                    </span>
                    <span>
                      <input type="radio" name="sidebar_bg" value="color_8" id="sidebar_bg_8">
                      <label for="sidebar_bg_8"></label>
                    </span>
                  </li>
                </ul>
              </li>
              <!--切换主题配色-->
            </ul>
          </div>
        </nav>
      </header>
      <!--End 头部信息-->

      <main class="lyear-layout-content" id="mainiframe" v-loading="loading" element-loading-text="拼命加载中">
        <iframe style="width: 100%; height: 100%; border:0px;" name="right" id="right"
          src="welcome2.html"></iframe>

        <!--  个人信息模态框（Modal） -->
        <form action="" class="form-horizontal" role="form">
          <div class="modal fade" id="myModal2" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
              <div class="modal-content">
                <div class="modal-header">
                  <h4 class="modal-title" id="myModalLabel">
                    个人信息
                  </h4>
                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                  </button>
                </div>
                <div class="modal-body" style="height: 100%;">
                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">登录名</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" v-model="user2.userName" placeholder="登录名">
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">真实姓名</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" v-model="user2.userRealName" placeholder="真实姓名">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">手机号</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" v-model="user2.userPhone" placeholder="手机号">
                    </div>
                  </div>
                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">邮件地址</label>
                    <div class="col-sm-7">
                      <el-input placeholder="邮件地址" v-model="user2.eMail">
                        <template slot="append">.com</template>
                      </el-input>
                      <!-- <input class="form-control" type="text" v-model="user2.eMail" placeholder="邮件地址"> -->
                    </div>
                  </div>

                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">角色</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" v-model="user2.userRoles" placeholder="角色">
                    </div>
                  </div>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                  <!-- <input type="button" data-dismiss="modal"  class="btn btn-primary" @click="userupdate()" value="提交"/> -->
                  <el-button id="button" data-dismiss="modal" class="btn btn-primary" type="primary"
                    @click.native.prevent="userupdate" :loading="loading">提交</el-button>
                </div>
              </div><!-- /.modal-content -->
            </div><!-- /.modal -->
          </div>
        </form>
        <!-- 重置密码模态框（Modal） -->
        <form action="" class="form-horizontal" role="form">
          <div class="modal fade" id="myModal3" tabindex="-1" role="dialog" aria-labelledby="myModalLabel"
            aria-hidden="true">
            <div class="modal-dialog">
              <div class="modal-content">
                <div class="modal-header">
                  <h4 class="modal-title" id="myModalLabel">
                    修改密码
                  </h4>
                  <button type="button" class="close" data-dismiss="modal" aria-hidden="true">
                    &times;
                  </button>
                </div>
                <div class="modal-body" style="height: 100%;">

                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">用户密码</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" id="a1" placeholder="当前用户密码">
                    </div>
                  </div>
                </div>
                <div class="modal-body" style="height: 100%;">

                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">修改密码</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" id="a2" placeholder="请输入修改密码">
                    </div>
                  </div>
                </div>
                <div class="modal-body" style="height: 100%;">

                  <div class="form-group">
                    <label for="lastname" class="col-sm-3 control-label">确定密码</label>
                    <div class="col-sm-7">
                      <input class="form-control" type="text" id="a3" placeholder="确定密码">
                    </div>
                  </div>
                </div>
                <div class="modal-footer">
                  <button type="button" class="btn btn-default" data-dismiss="modal">关闭</button>
                  <!-- <input type="button"  data-dismiss="modal" class="btn btn-primary" @click="pwdupdate()" value="提交"/> -->
                  <el-button id="button" data-dismiss="modal" class="btn btn-primary" type="primary"
                    @click.native.prevent="pwdupdate" :loading="loading">提交</el-button>
                </div>
              </div><!-- /.modal-content -->
            </div><!-- /.modal -->
          </div>
        </form>
      </main>

      <!--End 页面主要内容-->
    </div>
  </div>

  <script type="text/javascript" src="js/jquery.min.js"></script>
  <script type="text/javascript" src="js/bootstrap.min.js"></script>
  <script type="text/javascript" src="js/perfect-scrollbar.min.js"></script>
  <script type="text/javascript" src="js/main.min.js"></script>

  <!--图表插件-->
  <script type="text/javascript" src="js/Chart.js"></script>

  <script src="https://cdn.bootcss.com/zTree.v3/3.5.40/js/jquery.ztree.core.min.js"></script>
  <script src="https://cdn.bootcss.com/zTree.v3/3.5.40/js/jquery.ztree.excheck.min.js"></script>
  <link href="https://cdn.bootcss.com/zTree.v3/3.5.40/css/zTreeStyle/zTreeStyle.css" rel="stylesheet">

  <script src="http://code.jquery.com/jquery-migrate-1.2.1.js"></script>


  <!-- <script src="https://cdn.bootcss.com/vue/2.6.9/vue.min.js"></script>
<script src="https://cdn.bootcss.com/axios/0.19.0/axios.min.js"></script> -->
  <script src="vue js/vue/vue.min.js"></script>
  <script src="vue js/axios.min.js"></script>
  <!-- 引入样式 -->
  <link rel="stylesheet" href="https://unpkg.com/element-ui/lib/theme-chalk/index.css">
  <!-- 引入组件库 -->
  <script src="https://unpkg.com/element-ui/lib/index.js"></script>
  <script type="text/javascript">
    setTimeout(function () { location.reload() }, 1000 * 60 * 10); //指定10分钟刷新一次
    new Vue({
      el: "#app",
      data() {
        return {
          data: [],
          organ: {},
          loading: false,
          menu: {},
          user: {},
          user2: {},
          username: "",
          userid: "",
          admin: [],
          organ: [],
          defaultProps: {
            children: 'children',
            label: 'name'
          },
        }

      },
      created() {
        this.getlist()
      },
      methods: {
        go(path) {
          $("iframe").attr("src", path);
        },
        getlist() {
          this.username = window.localStorage.getItem("username")
          this.loading = true;
          setTimeout(() => {
            this.loading = false;
            this.id = window.localStorage.getItem("userid")
            axios.get("http://localhost:8888/menu/1").then(res => {

              this.arraytotree(res.data);

            }).catch(res => {
              this.$message.error('请重新登陆！！！');

              // setTimeout(function(){
              //   location='lyear_pages_login.html';
              // }, 500);

            })
          }, 2000);
        },
        person() {
          this.userid = window.localStorage.getItem("userid")
          axios.get("http://localhost:8888/findById/" + this.userid)
            .then(res => {
              this.user2 = res.data
              console.log(res)
            })
            .catch(err => {
              console.error(err);
            })
        },
        personpwd() {
          this.user = {}
        },
        userupdate() {
          this.userid = window.localStorage.getItem("userid")
          this.user2.userId = this.userid
          axios.post("http://localhost:8888/userupdate", this.user2)
            .then(res => {
              this.loading = true;
              setTimeout(() => {
                this.loading = false;
                this.$message({
                  message: '恭喜你，修改成功',
                  type: 'success'
                });
              }, 2000);
              this.getlist(1)
              console.log(res)
            })
            .catch(err => {
              console.error(err);
            })
        },
        pwdupdate() {
          this.userid = window.localStorage.getItem("userid")
          this.user.userId = this.userid
          axios.get("http://localhost:8888/findById/" + this.userid).then(res => {
            if (res.data.userPwd==$("#a1").val()) {
              if($("#a2").val()==$("#a3").val()){
                this.user.userPwd = $("#a2").val();
                axios.post("http://localhost:8888/userupdatepwd", this.user)
                .then(res => {
                  this.loading = true;
                  setTimeout(() => {
                    this.loading = false;
                    this.$message({
                      message: '恭喜你，重置密码成功',
                      type: 'success'
                    });
                    setTimeout(function () {
                      location = "lyear_pages_login.html";
                    }, 500);
                  }, 2000);
                  this.getlist(1)
                  console.log(res)
                })
                .catch(err => {
                  console.error(err);
                })
              }
              else{
                alert("两次密码不一致")
                $("#a1").val("");
                $("#a2").val("");
                $("#a3").val("");
              }
            }
            else{
              alert("当前密码输入错误")
              $("#a1").val("");
                $("#a2").val("");
                $("#a3").val("");
            }
          })
        },

        handleNodeClick(data) {
          this.organ = data;
          window.localStorage.setItem("id", this.organ.id);
          // alert(this.organ.id)
          console.log(data);
        },
        //数组转化为树
        arraytotree(arr) {
          console.log(arr)

          var top = [], sub = [], tempObj = {};

          arr.forEach(function (item) {

            if (item.pId == "0") { // 顶级分类
              top.push(item)

            } else {
              sub.push(item) // 其他分类
            }
            item.children = []; // 默然添加children属性

            tempObj[item.id] = item // 用当前分类的id做key，存储在tempObj中

          })

          sub.forEach(function (item) {

            // 取父级
            var parent = tempObj[item.pId] || { 'children': [] }

            // 把当前分类加入到父级的children中
            parent.children.push(item)

          })
          // alert(JSON.stringify(top))
          this.data = top;

          return top

        },
        error() {
          location = "login.html";
        }
      }
    })
    $(function () {
      mainIframe();
    })
    function mainIframe() {
      var he = window.innerHeight;
      $("#mainiframe").css("height", he - 20);
    }
    $(window).resize(function () {
      mainIframe();
    })

  </script>


</body>

</html>